<<<<<<< HEAD
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		
	}
	
	function index(){
		
		if($this->input->post('act') == 'login'){
			$ret['url_title'] = '返回登录页';
			$ret['url_next']="javascript:history.go(-1)";
			
			$username = $this->input->post('username');
			$password = $this->input->post('password');
			$captcha = $this->input->post('captcha');
			
			if($username==''){
				$ret['msg'] = '手机号/邮箱';
			}elseif ($password==''){
				$ret['msg'] = '请输入密码';
			}
			//elseif ($captcha==''){
				//$ret['msg'] = '请输入验证码';
			//}//elseif ($captcha!=$_SESSION['captcha']){
				//$ret['msg'] = '您输入的验证码不正确';
			//}
			else{
				$this->load->model('User_model', 'user');
				$tmpRow = $this->user->check_login_errnum($username);
				if($tmpRow && $tmpRow['error_num']>=5){
					$ret['msg'] = '操作失误过多,账户已被锁定,请联系客服解锁或者明日再试';
				}else{
					$user = $this->user->check_login($username,$password);
					if(isset($user['user_id'])){
						if($user['fstatus']==3){
							$ret['msg'] = '账户已注销';
						}
						elseif($user['fstatus']==4){
							$ret['msg'] = '账户已冻结';
						}
						elseif($user['fstatus']==0){
							$ret['msg'] = '账户已关闭';
						}else{
							$ip = $this->input->ip_address();
							$now = time();
							$user['login_time'] = $now;
							$this->session->set_userdata('rsh_user',$user);
							
							$user = $this->user->get_by_uid($user['user_id']);
							$setArr = array(
								'logintime' => $user['logintime']+1,
								'uptime' => $user['lasttime'],
								'upip' => $user['lastip'],
								'lasttime' => $now,
								'error_num' => 0,
								'lastip' => $ip,
							);
							$this->user->update($setArr,array('user_id'=>$user['user_id']));
							$this->user->update_invest_rank($user['user_id'],$user['invest_score']);
							//新增 添加登录日志
							$addLog = array(
								'login_name' => $username,
								'login_state' => 11,
								'login_time' => $now,
								'login_ip' => $ip
							);
							$this->user->add_user_login_log($addLog);
							$this->js->go('/zhs_mobile/ucenter.html');
							$ret['msg'] = '登录成功';
							$ret['url_title'] = '正前往用户中心';
							$ret['url_next']="/zhs_mobile/ucenter.html";
						}
					}else{
						$ret['msg'] = '账户或密码错误，请确认';
					}
				}
			}
			$this->load->view('zhs_mobile/msg',$ret);
		}else{
			$user = $this->session->userdata('rsh_user');
			if(isset($user['user_id']) && $user['user_id'] > 0){
				$this->js->go('/zhs_mobile/ucenter.html');
			}
			else {
				$data['tab'] = 2;
				$this->load->view('zhs_mobile/login',$data);
			}
		}
	}
	function downAPP(){
		if(is_file(DOWN_APP)) {
        header('Content-Description: File Transfer'); 
				header('Content-Type: application/octet-stream'); 
				header('Content-Disposition: attachment; filename='.basename(DOWN_APP)); 
				header('Content-Transfer-Encoding: binary'); 
				header('Expires: 0'); 
				header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
				header('Pragma: public'); 
				header('Content-Length: ' . filesize(DOWN_APP)); 
				ob_clean(); 
				flush(); 
				readfile(DOWN_APP); 
				exit;
    }else{
        echo "文件不存在！";
        exit;
    }
	}
=======
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends CI_Controller {
    
	function __construct(){
		parent::__construct();
		
	}
	
	function index(){
		
		if($this->input->post('act') == 'login'){
			$ret['url_title'] = '返回登录页';
			$ret['url_next']="javascript:history.go(-1)";
			
			$username = $this->input->post('username');
			$password = $this->input->post('password');
			$captcha = $this->input->post('captcha');
			
			if($username==''){
				$ret['msg'] = '手机号/邮箱';
			}elseif ($password==''){
				$ret['msg'] = '请输入密码';
			}
			//elseif ($captcha==''){
				//$ret['msg'] = '请输入验证码';
			//}//elseif ($captcha!=$_SESSION['captcha']){
				//$ret['msg'] = '您输入的验证码不正确';
			//}
			else{
				$this->load->model('User_model', 'user');
				$tmpRow = $this->user->check_login_errnum($username);
				if($tmpRow && $tmpRow['error_num']>=5){
					$ret['msg'] = '操作失误过多,账户已被锁定,请联系客服解锁或者明日再试';
				}else{
					$user = $this->user->check_login($username,$password);
					if(isset($user['user_id'])){
						if($user['fstatus']==3){
							$ret['msg'] = '账户已注销';
						}
						elseif($user['fstatus']==4){
							$ret['msg'] = '账户已冻结';
						}
						elseif($user['fstatus']==0){
							$ret['msg'] = '账户已关闭';
						}else{
							$ip = $this->input->ip_address();
							$now = time();
							$user['login_time'] = $now;
							$this->session->set_userdata('rsh_user',$user);
							
							$user = $this->user->get_by_uid($user['user_id']);
							$setArr = array(
								'logintime' => $user['logintime']+1,
								'uptime' => $user['lasttime'],
								'upip' => $user['lastip'],
								'lasttime' => $now,
								'error_num' => 0,
								'lastip' => $ip,
							);
							$this->user->update($setArr,array('user_id'=>$user['user_id']));
							$this->user->update_invest_rank($user['user_id'],$user['invest_score']);
							//新增 添加登录日志
							$addLog = array(
								'login_name' => $username,
								'login_state' => 11,
								'login_time' => $now,
								'login_ip' => $ip
							);
							$this->user->add_user_login_log($addLog);
							$this->js->go('/zhs_mobile/ucenter.html');
							$ret['msg'] = '登录成功';
							$ret['url_title'] = '正前往用户中心';
							$ret['url_next']="/zhs_mobile/ucenter.html";
						}
					}else{
						$ret['msg'] = '账户或密码错误，请确认';
					}
				}
			}
			$this->load->view('zhs_mobile/msg',$ret);
		}else{
			$user = $this->session->userdata('rsh_user');
			if(isset($user['user_id']) && $user['user_id'] > 0){
				$this->js->go('/zhs_mobile/ucenter.html');
			}
			else {
				$data['tab'] = 2;
				$this->load->view('zhs_mobile/login',$data);
			}
		}
	}
	function downAPP(){
		if(is_file(DOWN_APP)) {
        header('Content-Description: File Transfer'); 
				header('Content-Type: application/octet-stream'); 
				header('Content-Disposition: attachment; filename='.basename(DOWN_APP)); 
				header('Content-Transfer-Encoding: binary'); 
				header('Expires: 0'); 
				header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
				header('Pragma: public'); 
				header('Content-Length: ' . filesize(DOWN_APP)); 
				ob_clean(); 
				flush(); 
				readfile(DOWN_APP); 
				exit;
    }else{
        echo "文件不存在！";
        exit;
    }
	}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}